package com.sakana.test1;

import javax.lang.model.type.TypeMirror;
import javax.sound.midi.Soundbank;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.time.LocalDate;
import java.time.temporal.ChronoUnit;
import java.util.Date;
import java.util.Locale;

public class test3 {
    public static void main(String[] args) throws ParseException {
        //jdk7
        //1.计算出生年月日的毫秒值
        String birthday = "2000年1月1日";
        SimpleDateFormat sdf = new SimpleDateFormat("yyyy年MM月dd日");
        Date date=sdf.parse(birthday);
        long birthdayTime=date.getTime();
        //2.获取当前时间的毫秒值
        long todayTime= System.currentTimeMillis();
        //3.计算间隔多少天
        long time=todayTime-birthdayTime;
        System.out.println(time/1000/60/60/24);

        //jdk8
        LocalDate ld1=LocalDate.of(2000,1,1);
        LocalDate ld2=LocalDate.now();
        long days= ChronoUnit.DAYS.between(ld1,ld2);
        System.out.println(days);

    }
}
